<?php
	$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
	$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
	
	$offset = ($page-1)*$rows;
	$result = array();

	include 'conn.php';
	
	$rs = mysql_query("select count(*) from user");
	$row = mysql_fetch_row($rs);
	$result["total"] = $row[0];
	
	$where = "Username like '%$SearchBox%' or UserType like '%$SearchBox%' or StaffName like '%$SearchBox%' or CentreId like '%$SearchBox%' or 
	ContactNumber like '%$SearchBox%' or Email like '%$SearchBox%";  
	$rs = mysql_query("select * from user where ".$where." limit $offset,$rows");
	$items = array();
	while($row = mysql_fetch_object($rs)){
		array_push($items, $row);
	}
	$result["rows"] = $items;

	echo json_encode($result);

?>